
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 08/17/2013 17:12:21
-- Generated from EDMX file: D:\Projects\MyProjects\HNCSolutions\trunk\HNCSolutions\HNCSolutions\Models\HNCSolutionsModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [HNCSolutions];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[DoanGioiThieuSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DoanGioiThieuSet];
GO
IF OBJECT_ID(N'[dbo].[Menu]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Menu];
GO
IF OBJECT_ID(N'[dbo].[URL]', 'U') IS NOT NULL
    DROP TABLE [dbo].[URL];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'DoanGioiThieuSet'
CREATE TABLE [dbo].[DoanGioiThieuSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [TenTieuDe] nvarchar(max)  NOT NULL,
    [TieuDeChinh] nvarchar(max)  NOT NULL,
    [HinhAnh] nvarchar(max)  NOT NULL,
    [TieuDePhu] nvarchar(max)  NULL,
    [NoiDung] nvarchar(max)  NULL,
    [URLId] int  NOT NULL
);
GO

-- Creating table 'URL'
CREATE TABLE [dbo].[URL] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LinkUrl] varchar(200)  NULL,
    [Action] varchar(50)  NULL,
    [Controller] varchar(50)  NULL
);
GO

-- Creating table 'Menu'
CREATE TABLE [dbo].[Menu] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Text] nvarchar(50)  NULL,
    [URLId] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'DoanGioiThieuSet'
ALTER TABLE [dbo].[DoanGioiThieuSet]
ADD CONSTRAINT [PK_DoanGioiThieuSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'URL'
ALTER TABLE [dbo].[URL]
ADD CONSTRAINT [PK_URL]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Menu'
ALTER TABLE [dbo].[Menu]
ADD CONSTRAINT [PK_Menu]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [URLId] in table 'DoanGioiThieuSet'
ALTER TABLE [dbo].[DoanGioiThieuSet]
ADD CONSTRAINT [FK_URLDoanGioiThieu]
    FOREIGN KEY ([URLId])
    REFERENCES [dbo].[URL]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_URLDoanGioiThieu'
CREATE INDEX [IX_FK_URLDoanGioiThieu]
ON [dbo].[DoanGioiThieuSet]
    ([URLId]);
GO

-- Creating foreign key on [URLId] in table 'Menu'
ALTER TABLE [dbo].[Menu]
ADD CONSTRAINT [FK_URLMenu]
    FOREIGN KEY ([URLId])
    REFERENCES [dbo].[URL]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_URLMenu'
CREATE INDEX [IX_FK_URLMenu]
ON [dbo].[Menu]
    ([URLId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------